<?php
require('set.php');
$userid = $_GET['userid'];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>User-Center</title>
</head>
<body>
<style>
.greenzt{
  color:green;
}
.redzt{
  color:red;
}
</style>
<section class="rt_wrap content mCustomScrollbar">
 <div class="rt_content">
 <div class="admin_tab_cont" style="display:block;">
       <div class="cont_col_lt mCustomScrollbar" style="height:500px;width:100%">
           <table class="table fl">
            <tr>
             <th>ID</th>
             <th>帖子</th>
             <th>状态</th>
             <th>操作</th>
            </tr>
            <tr>
            <?php 
            require('../cofd/common.php');
            $sql = "SELECT * FROM post WHERE fromer = $userid";
            $result = mysqli_query($conn, $sql);
            while($row = mysqli_fetch_assoc($result)){
             echo '<td class="center">';echo $row['id'];echo '</td>';
             echo '<td class="center">';echo $row['phead'];echo '</td>';
             echo '<td class="center">';if($row['zt'] == 1){
              echo '<span class="greenzt">审核通过</span>';
             }else{
              echo '<span class="redzt">审核中</span>';
             };echo '</td>';
             echo '<td class="center"><a onclick="delthepost('.$row['id'].')" class="inner_btn">删除</a></td>';
           echo'
            </tr>
            <tr>';
            }
             ?>
            </tr>
           </table>
       </div>
</div>
</section>
</body>
</html>
<script>
  var userid = sessionStorage.getItem('user');
	(function($){
		$(window).load(function(){
			$("a[rel='load-content']").click(function(e){
				e.preventDefault();
				var url=$(this).attr("href");
				$.get(url,function(data){
					$(".content .mCSB_container").append(data); 
					$(".content").mCustomScrollbar("scrollTo","h2:last");
				});
			});		
			$(".content").delegate("a[href='top']","click",function(e){
				e.preventDefault();
				$(".content").mCustomScrollbar("scrollTo",$(this).attr("href"));
			});	
		});
	})(jQuery);
</script>
<script>
 function delthepost(deltheid){
  if(!confirm('确定要删除该帖子吗？')){
    return false;
  }
  var numchan;
  deltheid = deltheid.toString();
  if(deltheid.length === 7){
    numchan = 0+''+deltheid;
  }else{
    numchan = deltheid;
  }
  loading_load_show();
   fetch('ht/delpost.php?id='+numchan)
   .then(response => response.json())
   .then(data => {
    if(data.code === 200){
      Qmsg.success(data.msg);
    }else{
      Qmsg.error(data.msg);
    }
    })
    loading_load_hide();
    setTimeout(function(){
      location.reload();
    },1000);
 }
</script>
